package com.ruoyi.web.controller.system;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.page.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.system.service.ISysMenuService;

import java.util.List;

/**
 * 菜单信息
 *
 * @author ruoyi
 */
@Api(tags = "(客户端) 菜单信息")
@RestController
@RequestMapping("/system/menu")
public class SysMenuController {
    @Autowired
    private ISysMenuService menuService;

    @GetMapping("/list")
    @ApiOperation(value = "查询全部菜单")
    public ResultEntity list() {
        List<SysMenu> menu = menuService.list(new LambdaQueryWrapper<SysMenu>().eq(SysMenu :: getParentId ,2000));
        menu.forEach(item -> {
            List childMenu = menuService.list(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId,item.getId()));
            item.setChildren(childMenu);
        });
        return ResultEntity.createSuccess(menu);
    }

}
